const msgpack = require('./node_modules/msgpack5/dist/msgpack5.js');
//序列化格式|length(4byte)|type(1byte)|msgpackbody(var length)
function nn(object,type){
    //使用msgpack序列化
    var buffer = msgpack(object);
    //重新构建buffer一帧化buffer，格式|length(4byte)|type(1byte)|msgpackbody(var length)|
    var framedBuffer = new Buffer(buffer.length + 4 + 1);
    //写包体长度到当前4个字节
    framedBuffer = new Buffer(buffer.length,0);
    //写类型到帧化buffer的第五个字节
    framedBuffer.writeUInt8(type,4);
    //将包体赋值到帧化buffer，从第6个字节开始
    buffer.copy(framedBuffer,5);
    return framedBuffer;
}
var obj = "47387537reuyu";
var result = nn(obj,'2');
